{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "8f384611",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Memory usage Starting MIMIC4Dataset init: 668.4 MB\n",
      "Initializing MIMIC4EHRDataset with tables: ['diagnoses_icd', 'procedures_icd', 'prescriptions', 'labevents'] (dev mode: True)\n",
      "Using default EHR config: /home/johnwu3/projects/PyHealth_Branch_Testing/PyHealth/pyhealth/datasets/configs/mimic4_ehr.yaml\n",
      "Memory usage Before initializing mimic4_ehr: 668.4 MB\n",
      "Initializing mimic4_ehr dataset from /srv/local/data/physionet.org/files/mimiciv/2.2/ (dev mode: False)\n",
      "Scanning table: diagnoses_icd from /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/diagnoses_icd.csv.gz\n",
      "Joining with table: /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/admissions.csv.gz\n",
      "Original path does not exist. Using alternative: /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/admissions.csv\n",
      "Scanning table: procedures_icd from /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/procedures_icd.csv.gz\n",
      "Joining with table: /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/admissions.csv.gz\n",
      "Original path does not exist. Using alternative: /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/admissions.csv\n",
      "Scanning table: prescriptions from /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/prescriptions.csv.gz\n",
      "Scanning table: labevents from /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/labevents.csv.gz\n",
      "Joining with table: /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/d_labitems.csv.gz\n",
      "Scanning table: patients from /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/patients.csv.gz\n",
      "Scanning table: admissions from /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/admissions.csv.gz\n",
      "Original path does not exist. Using alternative: /srv/local/data/physionet.org/files/mimiciv/2.2/hosp/admissions.csv\n",
      "Scanning table: icustays from /srv/local/data/physionet.org/files/mimiciv/2.2/icu/icustays.csv.gz\n",
      "Memory usage After initializing mimic4_ehr: 30751.7 MB\n",
      "Memory usage After EHR dataset initialization: 30751.7 MB\n",
      "Memory usage Before combining data: 30751.7 MB\n",
      "Combining data from ehr dataset\n",
      "Creating combined dataframe\n",
      "Memory usage After combining data: 30751.7 MB\n",
      "Memory usage Completed MIMIC4Dataset init: 30751.7 MB\n",
      "Setting task InHospitalMortalityMIMIC4 for mimic4 base dataset...\n",
      "Generating samples with 10 worker(s)...\n",
      "Collecting global event dataframe...\n",
      "Dev mode enabled: limiting to 1000 patients\n",
      "Collected dataframe with shape: (458197, 47)\n",
      "Generating samples for InHospitalMortalityMIMIC4 with 10 workers\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Collecting samples for InHospitalMortalityMIMIC4 from 10 workers: 100%|██████████| 1000/1000 [00:03<00:00, 304.76it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Caching samples to ../../test_cache_mortality_m4/InHospitalMortalityMIMIC4.parquet\n",
      "Failed to cache samples: failed to determine supertype of list[datetime[μs]] and object\n",
      "Label mortality vocab: {0: 0, 1: 1}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Processing samples: 100%|██████████| 723/723 [00:00<00:00, 1726.48it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generated 723 samples for task InHospitalMortalityMIMIC4\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "from pyhealth.datasets import MIMIC4Dataset\n",
    "\n",
    "dataset = MIMIC4Dataset(\n",
    "    ehr_root=\"/srv/local/data/physionet.org/files/mimiciv/2.2/\",\n",
    "    ehr_tables=[\"diagnoses_icd\", \"procedures_icd\", \"prescriptions\", \"labevents\"],\n",
    "    dev=True,\n",
    ")\n",
    "\n",
    "from pyhealth.tasks import InHospitalMortalityMIMIC4\n",
    "\n",
    "task = InHospitalMortalityMIMIC4()\n",
    "samples = dataset.set_task(task, num_workers=10, cache_dir=\"../../test_cache_mortality_m4\")\n",
    "\n",
    "from pyhealth.datasets import split_by_sample\n",
    "\n",
    "\n",
    "train_dataset, val_dataset, test_dataset = split_by_sample(\n",
    "    dataset=samples, ratios=[0.7, 0.1, 0.2]\n",
    ")\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ca618021",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found 1000 unique patient IDs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[Event(event_type='patients', timestamp=datetime.datetime(2025, 10, 7, 18, 30, 27, 968268), attr_dict={'gender': 'F', 'anchor_age': '64', 'anchor_year': '2115', 'anchor_year_group': '2008 - 2010', 'dod': None}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 8, 0), attr_dict={'hadm_id': '29020064', 'drug': 'BuPROPion (Sustained Release)', 'ndc': '00173094755', 'prod_strength': '100mg SR Tab', 'dose_val_rx': '200', 'dose_unit_rx': 'mg', 'route': 'PO', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 10, 0), attr_dict={'hadm_id': '29020064', 'drug': 'anastrozole', 'ndc': '00310020137', 'prod_strength': '1mg Tablet', 'dose_val_rx': '1', 'dose_unit_rx': 'mg', 'route': 'ORAL', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 10, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Simvastatin', 'ndc': '51079045420', 'prod_strength': '10mg Tablet', 'dose_val_rx': '10', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 10, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Multivitamins', 'ndc': '00904053061', 'prod_strength': '1 Tablet', 'dose_val_rx': '1', 'dose_unit_rx': 'TAB', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 10, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Aspirin', 'ndc': '00904404073', 'prod_strength': '81mg Tab', 'dose_val_rx': '81', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50813', 'label': 'Lactate', 'fluid': 'Blood', 'category': 'Blood Gas', 'value': '1.1', 'valuenum': '1.1', 'valueuom': 'mmol/L', 'flag': None, 'storetime': '2115-05-19 12:03:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50822', 'label': 'Potassium, Whole Blood', 'fluid': 'Blood', 'category': 'Blood Gas', 'value': '3.8', 'valuenum': '3.8', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-19 12:03:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50862', 'label': 'Albumin', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '4.4', 'valuenum': '4.4', 'valueuom': 'g/dL', 'flag': None, 'storetime': '2115-05-19 21:56:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50868', 'label': 'Anion Gap', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '13', 'valuenum': '13', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-19 12:57:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50882', 'label': 'Bicarbonate', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '29', 'valuenum': '29', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-19 12:57:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50893', 'label': 'Calcium, Total', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '9.9', 'valuenum': '9.9', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-19 21:56:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50902', 'label': 'Chloride', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '100', 'valuenum': '100', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-19 12:57:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50912', 'label': 'Creatinine', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '0.8', 'valuenum': '0.8', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-19 12:57:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50920', 'label': 'Estimated GFR (MDRD equation)', 'fluid': 'Blood', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-05-19 12:57:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50925', 'label': 'Folate', 'fluid': 'Blood', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': 'ng/mL', 'flag': None, 'storetime': '2115-05-19 23:42:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50930', 'label': 'Globulin', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '2.3', 'valuenum': '2.3', 'valueuom': 'g/dL', 'flag': None, 'storetime': '2115-05-19 21:56:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50931', 'label': 'Glucose', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '___', 'valuenum': '88', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-19 12:57:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50971', 'label': 'Potassium', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '3.8', 'valuenum': '3.8', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-19 12:57:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50976', 'label': 'Protein, Total', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '6.7', 'valuenum': '6.7', 'valueuom': 'g/dL', 'flag': None, 'storetime': '2115-05-19 21:56:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50983', 'label': 'Sodium', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '138', 'valuenum': '138', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-19 12:57:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50993', 'label': 'Thyroid Stimulating Hormone', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '1.7', 'valuenum': '1.7', 'valueuom': 'uIU/mL', 'flag': None, 'storetime': '2115-05-19 23:42:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51006', 'label': 'Urea Nitrogen', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '21', 'valuenum': '21', 'valueuom': 'mg/dL', 'flag': 'abnormal', 'storetime': '2115-05-19 12:57:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51010', 'label': 'Vitamin B12', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '467', 'valuenum': '467', 'valueuom': 'pg/mL', 'flag': None, 'storetime': '2115-05-19 23:42:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '50955', 'label': 'Light Green Top Hold', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '___', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51003', 'label': 'Troponin T', 'fluid': 'Blood', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': 'ng/mL', 'flag': None, 'storetime': '2115-05-19 14:03:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51237', 'label': 'INR(PT)', 'fluid': 'Blood', 'category': 'Hematology', 'value': '1.2', 'valuenum': '1.2', 'valueuom': None, 'flag': 'abnormal', 'storetime': '2115-05-19 12:51:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51274', 'label': 'PT', 'fluid': 'Blood', 'category': 'Hematology', 'value': '13.5', 'valuenum': '13.5', 'valueuom': 'sec', 'flag': 'abnormal', 'storetime': '2115-05-19 12:51:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51275', 'label': 'PTT', 'fluid': 'Blood', 'category': 'Hematology', 'value': '25.2', 'valuenum': '25.2', 'valueuom': 'sec', 'flag': None, 'storetime': '2115-05-19 12:51:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51146', 'label': 'Basophils', 'fluid': 'Blood', 'category': 'Hematology', 'value': '1.0', 'valuenum': '1', 'valueuom': '%', 'flag': None, 'storetime': '2115-05-19 12:33:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51200', 'label': 'Eosinophils', 'fluid': 'Blood', 'category': 'Hematology', 'value': '2.1', 'valuenum': '2.1', 'valueuom': '%', 'flag': None, 'storetime': '2115-05-19 12:33:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51221', 'label': 'Hematocrit', 'fluid': 'Blood', 'category': 'Hematology', 'value': '37.2', 'valuenum': '37.2', 'valueuom': '%', 'flag': None, 'storetime': '2115-05-19 12:28:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51222', 'label': 'Hemoglobin', 'fluid': 'Blood', 'category': 'Hematology', 'value': '13.2', 'valuenum': '13.2', 'valueuom': 'g/dL', 'flag': None, 'storetime': '2115-05-19 12:28:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51244', 'label': 'Lymphocytes', 'fluid': 'Blood', 'category': 'Hematology', 'value': '24.1', 'valuenum': '24.1', 'valueuom': '%', 'flag': None, 'storetime': '2115-05-19 12:33:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51248', 'label': 'MCH', 'fluid': 'Blood', 'category': 'Hematology', 'value': '29.9', 'valuenum': '29.9', 'valueuom': 'pg', 'flag': None, 'storetime': '2115-05-19 12:28:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51249', 'label': 'MCHC', 'fluid': 'Blood', 'category': 'Hematology', 'value': '35.4', 'valuenum': '35.4', 'valueuom': '%', 'flag': 'abnormal', 'storetime': '2115-05-19 12:28:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51250', 'label': 'MCV', 'fluid': 'Blood', 'category': 'Hematology', 'value': '85', 'valuenum': '85', 'valueuom': 'fL', 'flag': None, 'storetime': '2115-05-19 12:28:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51254', 'label': 'Monocytes', 'fluid': 'Blood', 'category': 'Hematology', 'value': '4.8', 'valuenum': '4.8', 'valueuom': '%', 'flag': None, 'storetime': '2115-05-19 12:33:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51256', 'label': 'Neutrophils', 'fluid': 'Blood', 'category': 'Hematology', 'value': '68.0', 'valuenum': '68', 'valueuom': '%', 'flag': None, 'storetime': '2115-05-19 12:33:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51265', 'label': 'Platelet Count', 'fluid': 'Blood', 'category': 'Hematology', 'value': '174', 'valuenum': '174', 'valueuom': 'K/uL', 'flag': None, 'storetime': '2115-05-19 12:28:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51277', 'label': 'RDW', 'fluid': 'Blood', 'category': 'Hematology', 'value': '13.3', 'valuenum': '13.3', 'valueuom': '%', 'flag': None, 'storetime': '2115-05-19 12:28:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51279', 'label': 'Red Blood Cells', 'fluid': 'Blood', 'category': 'Hematology', 'value': '4.40', 'valuenum': '4.4', 'valueuom': 'm/uL', 'flag': None, 'storetime': '2115-05-19 12:28:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 12, 2), attr_dict={'itemid': '51301', 'label': 'White Blood Cells', 'fluid': 'Blood', 'category': 'Hematology', 'value': '4.6', 'valuenum': '4.6', 'valueuom': 'K/uL', 'flag': None, 'storetime': '2115-05-19 12:28:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51463', 'label': 'Bacteria', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'FEW', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-05-19 16:40:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51464', 'label': 'Bilirubin', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'NEG', 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51466', 'label': 'Blood', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'NEG', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51476', 'label': 'Epithelial Cells', 'fluid': 'Urine', 'category': 'Hematology', 'value': '0', 'valuenum': '0', 'valueuom': '#/hpf', 'flag': None, 'storetime': '2115-05-19 16:40:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51478', 'label': 'Glucose', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'NEG', 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51484', 'label': 'Ketone', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'TR', 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51486', 'label': 'Leukocytes', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'TR', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51487', 'label': 'Nitrite', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'NEG', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51491', 'label': 'pH', 'fluid': 'Urine', 'category': 'Hematology', 'value': '5.0', 'valuenum': '5', 'valueuom': 'units', 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51492', 'label': 'Protein', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'NEG', 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51493', 'label': 'RBC', 'fluid': 'Urine', 'category': 'Hematology', 'value': '0', 'valuenum': '0', 'valueuom': '#/hpf', 'flag': None, 'storetime': '2115-05-19 16:40:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51498', 'label': 'Specific Gravity', 'fluid': 'Urine', 'category': 'Hematology', 'value': '1.019', 'valuenum': '1.019', 'valueuom': ' ', 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51506', 'label': 'Urine Appearance', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'Clear', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51508', 'label': 'Urine Color', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'Yellow', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51514', 'label': 'Urobilinogen', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'NEG', 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-19 15:50:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51516', 'label': 'WBC', 'fluid': 'Urine', 'category': 'Hematology', 'value': '11-20', 'valuenum': None, 'valueuom': '#/hpf', 'flag': 'abnormal', 'storetime': '2115-05-19 16:40:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51519', 'label': 'Yeast', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'NONE', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-05-19 16:40:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51087', 'label': 'Length of Urine Collection', 'fluid': 'Urine', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 0), attr_dict={'itemid': '51107', 'label': 'Urine tube, held', 'fluid': 'Urine', 'category': 'Chemistry', 'value': 'HOLD.  SPECIMEN TO BE HELD 48 HOURS AND DISCARDED.', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 2), attr_dict={'itemid': '50802', 'label': 'Base Excess', 'fluid': 'Blood', 'category': 'Blood Gas', 'value': '3', 'valuenum': '3', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-19 14:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 2), attr_dict={'itemid': '50804', 'label': 'Calculated Total CO2', 'fluid': 'Blood', 'category': 'Blood Gas', 'value': '29', 'valuenum': '29', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-19 14:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 2), attr_dict={'itemid': '50812', 'label': 'Intubated', 'fluid': 'Blood', 'category': 'Blood Gas', 'value': 'NOT INTUBATED.', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-05-19 14:03:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 2), attr_dict={'itemid': '50818', 'label': 'pCO2', 'fluid': 'Blood', 'category': 'Blood Gas', 'value': '41', 'valuenum': '41', 'valueuom': 'mm Hg', 'flag': None, 'storetime': '2115-05-19 14:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 2), attr_dict={'itemid': '50820', 'label': 'pH', 'fluid': 'Blood', 'category': 'Blood Gas', 'value': '7.45', 'valuenum': '7.45', 'valueuom': 'units', 'flag': None, 'storetime': '2115-05-19 14:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 2), attr_dict={'itemid': '50821', 'label': 'pO2', 'fluid': 'Blood', 'category': 'Blood Gas', 'value': '87', 'valuenum': '87', 'valueuom': 'mm Hg', 'flag': None, 'storetime': '2115-05-19 14:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 19, 14, 2), attr_dict={'itemid': '52033', 'label': 'Specimen Type', 'fluid': 'Blood', 'category': 'Blood Gas', 'value': 'ART.', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-05-19 14:03:00'}),\n",
       " Event(event_type='admissions', timestamp=datetime.datetime(2115, 5, 19, 14, 43), attr_dict={'hadm_id': '29020064', 'admission_type': 'EW EMER.', 'admission_location': 'EMERGENCY ROOM', 'insurance': 'Other', 'language': 'ENGLISH', 'marital_status': 'SINGLE', 'race': 'WHITE', 'discharge_location': 'HOME', 'dischtime': '2115-05-21 17:47:00', 'hospital_expire_flag': '0'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 17, 0), attr_dict={'hadm_id': '29020064', 'drug': '1/2 NS', 'ndc': '00338004304', 'prod_strength': '1000mL Bag', 'dose_val_rx': '1000', 'dose_unit_rx': 'mL', 'route': 'IV', 'stoptime': '2115-05-19 18:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 19, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Ciprofloxacin HCl', 'ndc': '00172531110', 'prod_strength': '250mg Tab', 'dose_val_rx': '250', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 19, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Pneumococcal Vac Polyvalent', 'ndc': '00006473900', 'prod_strength': '25mcg/0.5mL Vial', 'dose_val_rx': '0.5', 'dose_unit_rx': 'mL', 'route': 'IM', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 19, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Influenza Virus Vaccine', 'ndc': '33332001001', 'prod_strength': '0.5 mL Syringe', 'dose_val_rx': '0.5', 'dose_unit_rx': 'mL', 'route': 'IM', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 19, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Sodium Chloride 0.9%  Flush', 'ndc': '0', 'prod_strength': 'Syringe', 'dose_val_rx': '3', 'dose_unit_rx': 'mL', 'route': 'IV', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 20, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Heparin', 'ndc': '63323026201', 'prod_strength': '5000 Units / mL- 1mL Vial', 'dose_val_rx': '5000', 'dose_unit_rx': 'UNIT', 'route': 'SC', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 20, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Fluticasone-Salmeterol Diskus (100/50)', 'ndc': '00173069502', 'prod_strength': '100/50 mcg Diskus', 'dose_val_rx': '1', 'dose_unit_rx': 'INH', 'route': 'IH', 'stoptime': '2115-05-20 08:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 20, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Vitamin D', 'ndc': '10432017002', 'prod_strength': '400 Unit Tablet', 'dose_val_rx': '400', 'dose_unit_rx': 'UNIT', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 20, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Calcium Carbonate', 'ndc': '66553000401', 'prod_strength': '500mg Tablet', 'dose_val_rx': '500', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 20, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Fish Oil (Omega 3)', 'ndc': '10939033733', 'prod_strength': '1000 mg Cap', 'dose_val_rx': '2000', 'dose_unit_rx': 'mg', 'route': 'PO', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 22, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Sertraline', 'ndc': '00904586761', 'prod_strength': '100mg Tablet', 'dose_val_rx': '200', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 22, 0), attr_dict={'hadm_id': '29020064', 'drug': 'traZODONE', 'ndc': '00904399061', 'prod_strength': '50mg Tablet', 'dose_val_rx': '50', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 22, 0), attr_dict={'hadm_id': '29020064', 'drug': 'traZODONE', 'ndc': '00904399061', 'prod_strength': '50mg Tablet', 'dose_val_rx': '75', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2115-05-19 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 19, 23, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Acetaminophen', 'ndc': '51079000220', 'prod_strength': '325mg Tablet', 'dose_val_rx': '325-650', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50861', 'label': 'Alanine Aminotransferase (ALT)', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '25', 'valuenum': '25', 'valueuom': 'IU/L', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50868', 'label': 'Anion Gap', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '13', 'valuenum': '13', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50878', 'label': 'Asparate Aminotransferase (AST)', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '25', 'valuenum': '25', 'valueuom': 'IU/L', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50882', 'label': 'Bicarbonate', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '26', 'valuenum': '26', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50893', 'label': 'Calcium, Total', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '9.6', 'valuenum': '9.6', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50902', 'label': 'Chloride', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '106', 'valuenum': '106', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50912', 'label': 'Creatinine', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '0.7', 'valuenum': '0.7', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50931', 'label': 'Glucose', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '___', 'valuenum': '95', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50960', 'label': 'Magnesium', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '2.3', 'valuenum': '2.3', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50970', 'label': 'Phosphate', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '3.6', 'valuenum': '3.6', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50971', 'label': 'Potassium', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '3.8', 'valuenum': '3.8', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '50983', 'label': 'Sodium', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '141', 'valuenum': '141', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51003', 'label': 'Troponin T', 'fluid': 'Blood', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': 'ng/mL', 'flag': None, 'storetime': '2115-05-20 09:06:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51006', 'label': 'Urea Nitrogen', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '21', 'valuenum': '21', 'valueuom': 'mg/dL', 'flag': 'abnormal', 'storetime': '2115-05-20 08:04:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51221', 'label': 'Hematocrit', 'fluid': 'Blood', 'category': 'Hematology', 'value': '34.6', 'valuenum': '34.6', 'valueuom': '%', 'flag': 'abnormal', 'storetime': '2115-05-20 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51222', 'label': 'Hemoglobin', 'fluid': 'Blood', 'category': 'Hematology', 'value': '12.5', 'valuenum': '12.5', 'valueuom': 'g/dL', 'flag': None, 'storetime': '2115-05-20 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51248', 'label': 'MCH', 'fluid': 'Blood', 'category': 'Hematology', 'value': '30.8', 'valuenum': '30.8', 'valueuom': 'pg', 'flag': None, 'storetime': '2115-05-20 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51249', 'label': 'MCHC', 'fluid': 'Blood', 'category': 'Hematology', 'value': '36.1', 'valuenum': '36.1', 'valueuom': '%', 'flag': 'abnormal', 'storetime': '2115-05-20 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51250', 'label': 'MCV', 'fluid': 'Blood', 'category': 'Hematology', 'value': '85', 'valuenum': '85', 'valueuom': 'fL', 'flag': None, 'storetime': '2115-05-20 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51265', 'label': 'Platelet Count', 'fluid': 'Blood', 'category': 'Hematology', 'value': '169', 'valuenum': '169', 'valueuom': 'K/uL', 'flag': None, 'storetime': '2115-05-20 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51277', 'label': 'RDW', 'fluid': 'Blood', 'category': 'Hematology', 'value': '13.6', 'valuenum': '13.6', 'valueuom': '%', 'flag': None, 'storetime': '2115-05-20 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51279', 'label': 'Red Blood Cells', 'fluid': 'Blood', 'category': 'Hematology', 'value': '4.06', 'valuenum': '4.06', 'valueuom': 'm/uL', 'flag': 'abnormal', 'storetime': '2115-05-20 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 20, 6, 10), attr_dict={'itemid': '51301', 'label': 'White Blood Cells', 'fluid': 'Blood', 'category': 'Hematology', 'value': '4.8', 'valuenum': '4.8', 'valueuom': 'K/uL', 'flag': None, 'storetime': '2115-05-20 07:34:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 20, 9, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Senna', 'ndc': '00904516561', 'prod_strength': '1 Tablet', 'dose_val_rx': '1', 'dose_unit_rx': 'TAB', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 20, 16, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Aspirin', 'ndc': '63739002401', 'prod_strength': '325mg Tablet', 'dose_val_rx': '325', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2115, 5, 20, 20, 0), attr_dict={'hadm_id': '29020064', 'drug': 'Docusate Sodium', 'ndc': '00904224461', 'prod_strength': '100mg Capsule', 'dose_val_rx': '100', 'dose_unit_rx': 'mg', 'route': 'PO', 'stoptime': '2115-05-21 21:00:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 21, 6, 20), attr_dict={'itemid': '51221', 'label': 'Hematocrit', 'fluid': 'Blood', 'category': 'Hematology', 'value': '34.2', 'valuenum': '34.2', 'valueuom': '%', 'flag': 'abnormal', 'storetime': '2115-05-21 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 21, 6, 20), attr_dict={'itemid': '51222', 'label': 'Hemoglobin', 'fluid': 'Blood', 'category': 'Hematology', 'value': '12.0', 'valuenum': '12', 'valueuom': 'g/dL', 'flag': None, 'storetime': '2115-05-21 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 21, 6, 20), attr_dict={'itemid': '51248', 'label': 'MCH', 'fluid': 'Blood', 'category': 'Hematology', 'value': '30.1', 'valuenum': '30.1', 'valueuom': 'pg', 'flag': None, 'storetime': '2115-05-21 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 21, 6, 20), attr_dict={'itemid': '51249', 'label': 'MCHC', 'fluid': 'Blood', 'category': 'Hematology', 'value': '35.1', 'valuenum': '35.1', 'valueuom': '%', 'flag': 'abnormal', 'storetime': '2115-05-21 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 21, 6, 20), attr_dict={'itemid': '51250', 'label': 'MCV', 'fluid': 'Blood', 'category': 'Hematology', 'value': '86', 'valuenum': '86', 'valueuom': 'fL', 'flag': None, 'storetime': '2115-05-21 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 21, 6, 20), attr_dict={'itemid': '51265', 'label': 'Platelet Count', 'fluid': 'Blood', 'category': 'Hematology', 'value': '191', 'valuenum': '191', 'valueuom': 'K/uL', 'flag': None, 'storetime': '2115-05-21 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 21, 6, 20), attr_dict={'itemid': '51277', 'label': 'RDW', 'fluid': 'Blood', 'category': 'Hematology', 'value': '13.6', 'valuenum': '13.6', 'valueuom': '%', 'flag': None, 'storetime': '2115-05-21 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 21, 6, 20), attr_dict={'itemid': '51279', 'label': 'Red Blood Cells', 'fluid': 'Blood', 'category': 'Hematology', 'value': '3.99', 'valuenum': '3.99', 'valueuom': 'm/uL', 'flag': 'abnormal', 'storetime': '2115-05-21 07:34:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 5, 21, 6, 20), attr_dict={'itemid': '51301', 'label': 'White Blood Cells', 'fluid': 'Blood', 'category': 'Hematology', 'value': '6.2', 'valuenum': '6.2', 'valueuom': 'K/uL', 'flag': None, 'storetime': '2115-05-21 07:34:00'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '34831', 'icd_version': '9', 'seq_num': '1'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '5990', 'icd_version': '9', 'seq_num': '2'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '29620', 'icd_version': '9', 'seq_num': '3'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '78097', 'icd_version': '9', 'seq_num': '4'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '32723', 'icd_version': '9', 'seq_num': '5'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '79431', 'icd_version': '9', 'seq_num': '6'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': 'V1588', 'icd_version': '9', 'seq_num': '7'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '34690', 'icd_version': '9', 'seq_num': '8'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': 'V103', 'icd_version': '9', 'seq_num': '9'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': 'V4571', 'icd_version': '9', 'seq_num': '10'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': 'V8741', 'icd_version': '9', 'seq_num': '11'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '7291', 'icd_version': '9', 'seq_num': '12'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '7234', 'icd_version': '9', 'seq_num': '13'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '71590', 'icd_version': '9', 'seq_num': '14'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': '30981', 'icd_version': '9', 'seq_num': '15'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2115, 5, 21, 17, 47), attr_dict={'hadm_id': '29020064', 'icd_code': 'V1582', 'icd_version': '9', 'seq_num': '16'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50887', 'label': 'Blue Top Hold', 'fluid': 'Blood', 'category': 'Chemistry', 'value': 'HOLD.  DISCARD GREATER THAN 24 HRS OLD.', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50933', 'label': 'Green Top Hold (plasma)', 'fluid': 'Blood', 'category': 'Chemistry', 'value': 'HOLD.  DISCARD GREATER THAN 4 HOURS OLD.', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51146', 'label': 'Basophils', 'fluid': 'Blood', 'category': 'Hematology', 'value': '0.3', 'valuenum': '0.3', 'valueuom': '%', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51200', 'label': 'Eosinophils', 'fluid': 'Blood', 'category': 'Hematology', 'value': '1.7', 'valuenum': '1.7', 'valueuom': '%', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51221', 'label': 'Hematocrit', 'fluid': 'Blood', 'category': 'Hematology', 'value': '36.6', 'valuenum': '36.6', 'valueuom': '%', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51222', 'label': 'Hemoglobin', 'fluid': 'Blood', 'category': 'Hematology', 'value': '13.0', 'valuenum': '13', 'valueuom': 'g/dL', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51244', 'label': 'Lymphocytes', 'fluid': 'Blood', 'category': 'Hematology', 'value': '22.2', 'valuenum': '22.2', 'valueuom': '%', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51248', 'label': 'MCH', 'fluid': 'Blood', 'category': 'Hematology', 'value': '29.8', 'valuenum': '29.8', 'valueuom': 'pg', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51249', 'label': 'MCHC', 'fluid': 'Blood', 'category': 'Hematology', 'value': '35.5', 'valuenum': '35.5', 'valueuom': '%', 'flag': 'abnormal', 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51250', 'label': 'MCV', 'fluid': 'Blood', 'category': 'Hematology', 'value': '84', 'valuenum': '84', 'valueuom': 'fL', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51254', 'label': 'Monocytes', 'fluid': 'Blood', 'category': 'Hematology', 'value': '3.5', 'valuenum': '3.5', 'valueuom': '%', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51256', 'label': 'Neutrophils', 'fluid': 'Blood', 'category': 'Hematology', 'value': '72.3', 'valuenum': '72.3', 'valueuom': '%', 'flag': 'abnormal', 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51265', 'label': 'Platelet Count', 'fluid': 'Blood', 'category': 'Hematology', 'value': '221', 'valuenum': '221', 'valueuom': 'K/uL', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51277', 'label': 'RDW', 'fluid': 'Blood', 'category': 'Hematology', 'value': '13.7', 'valuenum': '13.7', 'valueuom': '%', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51279', 'label': 'Red Blood Cells', 'fluid': 'Blood', 'category': 'Hematology', 'value': '4.36', 'valuenum': '4.36', 'valueuom': 'm/uL', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51301', 'label': 'White Blood Cells', 'fluid': 'Blood', 'category': 'Hematology', 'value': '7.0', 'valuenum': '7', 'valueuom': 'K/uL', 'flag': None, 'storetime': '2115-12-14 11:37:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50955', 'label': 'Light Green Top Hold', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '___', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51003', 'label': 'Troponin T', 'fluid': 'Blood', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': 'ng/mL', 'flag': None, 'storetime': '2115-12-14 12:36:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50861', 'label': 'Alanine Aminotransferase (ALT)', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '25', 'valuenum': '25', 'valueuom': 'IU/L', 'flag': None, 'storetime': '2115-12-14 13:33:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50863', 'label': 'Alkaline Phosphatase', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '111', 'valuenum': '111', 'valueuom': 'IU/L', 'flag': 'abnormal', 'storetime': '2115-12-14 13:33:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50868', 'label': 'Anion Gap', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '17', 'valuenum': '17', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-12-14 12:25:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50878', 'label': 'Asparate Aminotransferase (AST)', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '35', 'valuenum': '35', 'valueuom': 'IU/L', 'flag': None, 'storetime': '2115-12-14 13:33:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50882', 'label': 'Bicarbonate', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '26', 'valuenum': '26', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-12-14 12:25:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50885', 'label': 'Bilirubin, Total', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '0.5', 'valuenum': '0.5', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-12-14 13:33:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50902', 'label': 'Chloride', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '100', 'valuenum': '100', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-12-14 12:25:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50912', 'label': 'Creatinine', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '0.7', 'valuenum': '0.7', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-12-14 12:25:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50920', 'label': 'Estimated GFR (MDRD equation)', 'fluid': 'Blood', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-12-14 12:25:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50931', 'label': 'Glucose', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '___', 'valuenum': '104', 'valueuom': 'mg/dL', 'flag': 'abnormal', 'storetime': '2115-12-14 12:25:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50956', 'label': 'Lipase', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '20', 'valuenum': '20', 'valueuom': 'IU/L', 'flag': None, 'storetime': '2115-12-14 13:33:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50971', 'label': 'Potassium', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '4.2', 'valuenum': '4.2', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-12-14 12:25:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '50983', 'label': 'Sodium', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '139', 'valuenum': '139', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2115-12-14 12:25:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 11, 10), attr_dict={'itemid': '51006', 'label': 'Urea Nitrogen', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '23', 'valuenum': '23', 'valueuom': 'mg/dL', 'flag': 'abnormal', 'storetime': '2115-12-14 12:25:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51462', 'label': 'Amorphous Crystals', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51463', 'label': 'Bacteria', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51464', 'label': 'Bilirubin', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51466', 'label': 'Blood', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51476', 'label': 'Epithelial Cells', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': '#/hpf', 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51478', 'label': 'Glucose', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51484', 'label': 'Ketone', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51486', 'label': 'Leukocytes', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51487', 'label': 'Nitrite', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51491', 'label': 'pH', 'fluid': 'Urine', 'category': 'Hematology', 'value': '8.0', 'valuenum': '8', 'valueuom': 'units', 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51492', 'label': 'Protein', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51493', 'label': 'RBC', 'fluid': 'Urine', 'category': 'Hematology', 'value': '1', 'valuenum': '1', 'valueuom': '#/hpf', 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51498', 'label': 'Specific Gravity', 'fluid': 'Urine', 'category': 'Hematology', 'value': '1.016', 'valuenum': '1.016', 'valueuom': ' ', 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51506', 'label': 'Urine Appearance', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51508', 'label': 'Urine Color', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51512', 'label': 'Urine Mucous', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51514', 'label': 'Urobilinogen', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51516', 'label': 'WBC', 'fluid': 'Urine', 'category': 'Hematology', 'value': '2', 'valuenum': '2', 'valueuom': '#/hpf', 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51519', 'label': 'Yeast', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'NONE', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2115-12-14 13:46:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51087', 'label': 'Length of Urine Collection', 'fluid': 'Urine', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 12, 12), attr_dict={'itemid': '51107', 'label': 'Urine tube, held', 'fluid': 'Urine', 'category': 'Chemistry', 'value': 'HOLD.  SPECIMEN TO BE HELD 48 HOURS AND DISCARDED.', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2115, 12, 14, 14, 10), attr_dict={'itemid': '51003', 'label': 'Troponin T', 'fluid': 'Blood', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': 'ng/mL', 'flag': None, 'storetime': '2115-12-14 15:45:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51087', 'label': 'Length of Urine Collection', 'fluid': 'Urine', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51103', 'label': 'Uhold', 'fluid': 'Urine', 'category': 'Chemistry', 'value': 'HOLD.', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51463', 'label': 'Bacteria', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51464', 'label': 'Bilirubin', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51466', 'label': 'Blood', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51469', 'label': 'Calcium Oxalate Crystals', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51476', 'label': 'Epithelial Cells', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': '#/hpf', 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51478', 'label': 'Glucose', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51484', 'label': 'Ketone', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51486', 'label': 'Leukocytes', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51487', 'label': 'Nitrite', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51491', 'label': 'pH', 'fluid': 'Urine', 'category': 'Hematology', 'value': '7.5', 'valuenum': '7.5', 'valueuom': 'units', 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51492', 'label': 'Protein', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51493', 'label': 'RBC', 'fluid': 'Urine', 'category': 'Hematology', 'value': '1', 'valuenum': '1', 'valueuom': '#/hpf', 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51498', 'label': 'Specific Gravity', 'fluid': 'Urine', 'category': 'Hematology', 'value': '1.012', 'valuenum': '1.012', 'valueuom': ' ', 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51506', 'label': 'Urine Appearance', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51508', 'label': 'Urine Color', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51512', 'label': 'Urine Mucous', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51514', 'label': 'Urobilinogen', 'fluid': 'Urine', 'category': 'Hematology', 'value': None, 'valuenum': None, 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51516', 'label': 'WBC', 'fluid': 'Urine', 'category': 'Hematology', 'value': '7', 'valuenum': '7', 'valueuom': '#/hpf', 'flag': 'abnormal', 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51519', 'label': 'Yeast', 'fluid': 'Urine', 'category': 'Hematology', 'value': 'NONE', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2118-09-22 01:55:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51087', 'label': 'Length of Urine Collection', 'fluid': 'Urine', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 1, 23), attr_dict={'itemid': '51107', 'label': 'Urine tube, held', 'fluid': 'Urine', 'category': 'Chemistry', 'value': 'HOLD.  SPECIMEN TO BE HELD 48 HOURS AND DISCARDED.', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '50933', 'label': 'Green Top Hold (plasma)', 'fluid': 'Blood', 'category': 'Chemistry', 'value': 'HOLD.  DISCARD GREATER THAN 4 HOURS OLD.', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '50887', 'label': 'Blue Top Hold', 'fluid': 'Blood', 'category': 'Chemistry', 'value': 'HOLD.  DISCARD GREATER THAN 24 HRS OLD.', 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': None}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '50868', 'label': 'Anion Gap', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '15', 'valuenum': '15', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2118-09-22 04:20:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '50882', 'label': 'Bicarbonate', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '28', 'valuenum': '28', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2118-09-22 04:20:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '50902', 'label': 'Chloride', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '101', 'valuenum': '101', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2118-09-22 04:20:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '50912', 'label': 'Creatinine', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '0.7', 'valuenum': '0.7', 'valueuom': 'mg/dL', 'flag': None, 'storetime': '2118-09-22 04:20:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '50920', 'label': 'Estimated GFR (MDRD equation)', 'fluid': 'Blood', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': None, 'flag': None, 'storetime': '2118-09-22 04:20:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '50931', 'label': 'Glucose', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '___', 'valuenum': '126', 'valueuom': 'mg/dL', 'flag': 'abnormal', 'storetime': '2118-09-22 04:20:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '50971', 'label': 'Potassium', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '3.8', 'valuenum': '3.8', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2118-09-22 04:20:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '50983', 'label': 'Sodium', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '140', 'valuenum': '140', 'valueuom': 'mEq/L', 'flag': None, 'storetime': '2118-09-22 04:20:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51006', 'label': 'Urea Nitrogen', 'fluid': 'Blood', 'category': 'Chemistry', 'value': '24', 'valuenum': '24', 'valueuom': 'mg/dL', 'flag': 'abnormal', 'storetime': '2118-09-22 04:20:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51003', 'label': 'Troponin T', 'fluid': 'Blood', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': 'ng/mL', 'flag': None, 'storetime': '2118-09-22 04:25:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51146', 'label': 'Basophils', 'fluid': 'Blood', 'category': 'Hematology', 'value': '0.2', 'valuenum': '0.2', 'valueuom': '%', 'flag': None, 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51200', 'label': 'Eosinophils', 'fluid': 'Blood', 'category': 'Hematology', 'value': '0.7', 'valuenum': '0.7', 'valueuom': '%', 'flag': None, 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51221', 'label': 'Hematocrit', 'fluid': 'Blood', 'category': 'Hematology', 'value': '35.7', 'valuenum': '35.7', 'valueuom': '%', 'flag': 'abnormal', 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51222', 'label': 'Hemoglobin', 'fluid': 'Blood', 'category': 'Hematology', 'value': '12.1', 'valuenum': '12.1', 'valueuom': 'g/dL', 'flag': None, 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51244', 'label': 'Lymphocytes', 'fluid': 'Blood', 'category': 'Hematology', 'value': '15.2', 'valuenum': '15.2', 'valueuom': '%', 'flag': 'abnormal', 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51248', 'label': 'MCH', 'fluid': 'Blood', 'category': 'Hematology', 'value': '29.4', 'valuenum': '29.4', 'valueuom': 'pg', 'flag': None, 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51249', 'label': 'MCHC', 'fluid': 'Blood', 'category': 'Hematology', 'value': '33.8', 'valuenum': '33.8', 'valueuom': '%', 'flag': None, 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51250', 'label': 'MCV', 'fluid': 'Blood', 'category': 'Hematology', 'value': '87', 'valuenum': '87', 'valueuom': 'fL', 'flag': None, 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51254', 'label': 'Monocytes', 'fluid': 'Blood', 'category': 'Hematology', 'value': '2.4', 'valuenum': '2.4', 'valueuom': '%', 'flag': None, 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51256', 'label': 'Neutrophils', 'fluid': 'Blood', 'category': 'Hematology', 'value': '81.4', 'valuenum': '81.4', 'valueuom': '%', 'flag': 'abnormal', 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51265', 'label': 'Platelet Count', 'fluid': 'Blood', 'category': 'Hematology', 'value': '178', 'valuenum': '178', 'valueuom': 'K/uL', 'flag': None, 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51277', 'label': 'RDW', 'fluid': 'Blood', 'category': 'Hematology', 'value': '13.5', 'valuenum': '13.5', 'valueuom': '%', 'flag': None, 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51279', 'label': 'Red Blood Cells', 'fluid': 'Blood', 'category': 'Hematology', 'value': '4.10', 'valuenum': '4.1', 'valueuom': 'm/uL', 'flag': 'abnormal', 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 3, 40), attr_dict={'itemid': '51301', 'label': 'White Blood Cells', 'fluid': 'Blood', 'category': 'Hematology', 'value': '9.6', 'valuenum': '9.6', 'valueuom': 'K/uL', 'flag': None, 'storetime': '2118-09-22 04:11:00'}),\n",
       " Event(event_type='admissions', timestamp=datetime.datetime(2118, 9, 22, 5, 24), attr_dict={'hadm_id': '22000889', 'admission_type': 'EU OBSERVATION', 'admission_location': 'EMERGENCY ROOM', 'insurance': 'Other', 'language': 'ENGLISH', 'marital_status': 'DIVORCED', 'race': 'WHITE - RUSSIAN', 'discharge_location': None, 'dischtime': '2118-09-22 14:45:00', 'hospital_expire_flag': '0'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2118, 9, 22, 9, 0), attr_dict={'hadm_id': '22000889', 'drug': 'TraZODone', 'ndc': '00904399061', 'prod_strength': '50mg Tablet', 'dose_val_rx': '75', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2118-09-22 19:00:00'}),\n",
       " Event(event_type='labevents', timestamp=datetime.datetime(2118, 9, 22, 9, 30), attr_dict={'itemid': '51003', 'label': 'Troponin T', 'fluid': 'Blood', 'category': 'Chemistry', 'value': None, 'valuenum': None, 'valueuom': 'ng/mL', 'flag': None, 'storetime': '2118-09-22 10:28:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2118, 9, 22, 10, 0), attr_dict={'hadm_id': '22000889', 'drug': 'Ibuprofen', 'ndc': '00904585461', 'prod_strength': '600mg Tablet', 'dose_val_rx': '600', 'dose_unit_rx': 'mg', 'route': 'PO', 'stoptime': '2118-09-22 19:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2118, 9, 22, 10, 0), attr_dict={'hadm_id': '22000889', 'drug': 'Cyclobenzaprine', 'ndc': '51079064420', 'prod_strength': '10 mg Tab', 'dose_val_rx': '5', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2118-09-22 19:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2118, 9, 22, 14, 0), attr_dict={'hadm_id': '22000889', 'drug': 'ClonazePAM', 'ndc': '51079088120', 'prod_strength': '0.5mg Tablet', 'dose_val_rx': '0.5', 'dose_unit_rx': 'mg', 'route': 'PO', 'stoptime': '2118-09-22 19:00:00'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2118, 9, 22, 14, 45), attr_dict={'hadm_id': '22000889', 'icd_code': '7242', 'icd_version': '9', 'seq_num': '1'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2118, 9, 22, 14, 45), attr_dict={'hadm_id': '22000889', 'icd_code': '30000', 'icd_version': '9', 'seq_num': '2'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2118, 9, 22, 14, 45), attr_dict={'hadm_id': '22000889', 'icd_code': '27800', 'icd_version': '9', 'seq_num': '3'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2118, 9, 22, 14, 45), attr_dict={'hadm_id': '22000889', 'icd_code': '7291', 'icd_version': '9', 'seq_num': '4'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2118, 9, 22, 14, 45), attr_dict={'hadm_id': '22000889', 'icd_code': '7234', 'icd_version': '9', 'seq_num': '5'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2118, 9, 22, 14, 45), attr_dict={'hadm_id': '22000889', 'icd_code': '53081', 'icd_version': '9', 'seq_num': '6'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2118, 9, 22, 14, 45), attr_dict={'hadm_id': '22000889', 'icd_code': '2720', 'icd_version': '9', 'seq_num': '7'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2118, 9, 22, 14, 45), attr_dict={'hadm_id': '22000889', 'icd_code': '29630', 'icd_version': '9', 'seq_num': '8'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2118, 9, 22, 14, 45), attr_dict={'hadm_id': '22000889', 'icd_code': 'V103', 'icd_version': '9', 'seq_num': '9'}),\n",
       " Event(event_type='diagnoses_icd', timestamp=datetime.datetime(2118, 9, 22, 14, 45), attr_dict={'hadm_id': '22000889', 'icd_code': 'V5869', 'icd_version': '9', 'seq_num': '10'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2118, 9, 22, 20, 0), attr_dict={'hadm_id': '22000889', 'drug': 'LaMOTrigine', 'ndc': '00093046301', 'prod_strength': '100mg Tablet', 'dose_val_rx': '100', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2118-09-22 19:00:00'}),\n",
       " Event(event_type='prescriptions', timestamp=datetime.datetime(2118, 9, 23, 8, 0), attr_dict={'hadm_id': '22000889', 'drug': 'Sertraline', 'ndc': '00904586761', 'prod_strength': '100mg Tablet', 'dose_val_rx': '200', 'dose_unit_rx': 'mg', 'route': 'PO/NG', 'stoptime': '2118-09-22 19:00:00'})]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset.get_patient(dataset.unique_patient_ids[0]).get_events()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a66e489f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'patient_id': '11625970',\n",
       " 'admission_id': '20671706',\n",
       " 'labs': tensor([[  0.0000,   0.0000, 136.0000,   0.0000,   0.0000,   0.0000,   4.3000,\n",
       "            0.0000,   0.0000,   0.0000,  97.0000,   0.0000,   0.0000,   0.0000,\n",
       "            0.0000,   0.0000, 160.0000,   0.0000,   0.0000,   0.0000,   2.0000,\n",
       "           11.0000,   0.0000,   0.0000,   0.0000,   0.0000,   3.3000]]),\n",
       " 'mortality': tensor([0.])}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "samples[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3b642c1d",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/johnwu3/miniconda3/envs/medical_coding_demo/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "RNN(\n",
      "  (embedding_model): EmbeddingModel(embedding_layers=ModuleDict(\n",
      "    (labs): Linear(in_features=27, out_features=128, bias=True)\n",
      "  ))\n",
      "  (rnn): ModuleDict(\n",
      "    (labs): RNNLayer(\n",
      "      (dropout_layer): Dropout(p=0.5, inplace=False)\n",
      "      (rnn): GRU(128, 128, batch_first=True)\n",
      "    )\n",
      "  )\n",
      "  (fc): Linear(in_features=128, out_features=1, bias=True)\n",
      ")\n",
      "Metrics: ['roc_auc']\n",
      "Device: cuda\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Evaluation: 100%|██████████| 5/5 [00:00<00:00,  7.76it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'roc_auc': 0.6621438263229308, 'loss': 0.6749732613563537}\n",
      "Training:\n",
      "Batch size: 32\n",
      "Optimizer: <class 'torch.optim.adam.Adam'>\n",
      "Optimizer params: {'lr': 0.0001}\n",
      "Weight decay: 0.0\n",
      "Max grad norm: None\n",
      "Val dataloader: <torch.utils.data.dataloader.DataLoader object at 0x7ff8ea199f90>\n",
      "Monitor: roc_auc\n",
      "Monitor criterion: max\n",
      "Epochs: 10\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Epoch 0 / 10: 100%|██████████| 16/16 [00:00<00:00, 23.26it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Train epoch-0, step-16 ---\n",
      "loss: 0.6445\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Evaluation: 100%|██████████| 3/3 [00:00<00:00, 14.04it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Eval epoch-0, step-16 ---\n",
      "roc_auc: 0.3944\n",
      "loss: 0.6112\n",
      "New best roc_auc score (0.3944) at epoch-0, step-16\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Epoch 1 / 10: 100%|██████████| 16/16 [00:00<00:00, 226.97it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Train epoch-1, step-32 ---\n",
      "loss: 0.5758\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Evaluation: 100%|██████████| 3/3 [00:00<00:00, 591.80it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Eval epoch-1, step-32 ---\n",
      "roc_auc: 0.3803\n",
      "loss: 0.5449\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Epoch 2 / 10: 100%|██████████| 16/16 [00:00<00:00, 276.68it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Train epoch-2, step-48 ---\n",
      "loss: 0.5070\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Evaluation: 100%|██████████| 3/3 [00:00<00:00, 644.62it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Eval epoch-2, step-48 ---\n",
      "roc_auc: 0.3451\n",
      "loss: 0.4745\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Epoch 3 / 10: 100%|██████████| 16/16 [00:00<00:00, 259.23it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Train epoch-3, step-64 ---\n",
      "loss: 0.4340\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Evaluation: 100%|██████████| 3/3 [00:00<00:00, 623.38it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Eval epoch-3, step-64 ---\n",
      "roc_auc: 0.4225\n",
      "loss: 0.3852\n",
      "New best roc_auc score (0.4225) at epoch-3, step-64\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Epoch 4 / 10: 100%|██████████| 16/16 [00:00<00:00, 209.86it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Train epoch-4, step-80 ---\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loss: 0.3323\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Evaluation: 100%|██████████| 3/3 [00:00<00:00, 554.34it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Eval epoch-4, step-80 ---\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "roc_auc: 0.4225\n",
      "loss: 0.2752\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Epoch 5 / 10: 100%|██████████| 16/16 [00:00<00:00, 153.47it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Train epoch-5, step-96 ---\n",
      "loss: 0.2137\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Evaluation: 100%|██████████| 3/3 [00:00<00:00, 617.11it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Eval epoch-5, step-96 ---\n",
      "roc_auc: 0.4225\n",
      "loss: 0.1670\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Epoch 6 / 10: 100%|██████████| 16/16 [00:00<00:00, 243.23it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Train epoch-6, step-112 ---\n",
      "loss: 0.1249\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Evaluation: 100%|██████████| 3/3 [00:00<00:00, 648.24it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Eval epoch-6, step-112 ---\n",
      "roc_auc: 0.4225\n",
      "loss: 0.1178\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Epoch 7 / 10: 100%|██████████| 16/16 [00:00<00:00, 259.20it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Train epoch-7, step-128 ---\n",
      "loss: 0.0980\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Evaluation: 100%|██████████| 3/3 [00:00<00:00, 553.61it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Eval epoch-7, step-128 ---\n",
      "roc_auc: 0.4225\n",
      "loss: 0.1035\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Epoch 8 / 10: 100%|██████████| 16/16 [00:00<00:00, 251.54it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Train epoch-8, step-144 ---\n",
      "loss: 0.0860\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Evaluation: 100%|██████████| 3/3 [00:00<00:00, 643.27it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Eval epoch-8, step-144 ---\n",
      "roc_auc: 0.4225\n",
      "loss: 0.0961\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Epoch 9 / 10: 100%|██████████| 16/16 [00:00<00:00, 238.19it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Train epoch-9, step-160 ---\n",
      "loss: 0.0881\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Evaluation: 100%|██████████| 3/3 [00:00<00:00, 652.81it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--- Eval epoch-9, step-160 ---\n",
      "roc_auc: 0.4225\n",
      "loss: 0.0912\n",
      "Loaded best model\n"
     ]
    }
   ],
   "source": [
    "from pyhealth.datasets import get_dataloader\n",
    "train_dataloader = get_dataloader(train_dataset, batch_size=32, shuffle=True)\n",
    "val_dataloader = get_dataloader(val_dataset, batch_size=32, shuffle=False)\n",
    "test_dataloader = get_dataloader(test_dataset, batch_size=32, shuffle=False)\n",
    "\n",
    "from pyhealth.models import RNN\n",
    "\n",
    "model = RNN(\n",
    "    dataset=samples,\n",
    ")\n",
    "\n",
    "from pyhealth.trainer import Trainer\n",
    "\n",
    "trainer = Trainer(model=model, metrics=[\"roc_auc\"])\n",
    "print(trainer.evaluate(test_dataloader))\n",
    "\n",
    "trainer.train(\n",
    "    train_dataloader=train_dataloader,\n",
    "    val_dataloader=val_dataloader,\n",
    "    epochs=10,\n",
    "    monitor=\"roc_auc\",  # Monitor roc_auc specifically\n",
    "    optimizer_params={\"lr\": 1e-4}  # Using learning rate of 1e-4\n",
    ")\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "medical_coding_demo",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
